Ext.define('PJ.view.registrationmanagement.BaseCategoryTree', {
    extend: 'AM.default.DefaultTree',
    alias: 'widget.baseCategoryTree',
    title: "基础分类树",
    
    
    initComponent: function(){
    	this.store = Ext.create('PJ.' + prototype + '.registrationmanagement.BaseCategoryTree');
        this.callParent(arguments);
    },
	
//    doLoad: function(){
////            this.store.load();
//    },
    listeners: {
    	//显示树的一级菜单
		load: function(treeStore, node, records, successful, eOpts){
			if (node.data.id==1&&records != null&&node.hasChildNodes()) {
				if(node.data.id==1)
					this.fireEvent("itemclick",this.view,records[0]); //点击展开节点
			}
		},
        itemclick: function(view, record, htmlelement, index, eventObject, object){
        	if(eventObject){
        		eventObject.stopEvent();
        	}
            var gridPanel = this.up("container").down("grid");
            gridPanel.searchBaseCategoryId = record.data.id;
            gridPanel.searchCategoryCode = record.raw.catalogCode;
            // 设置grid可以被刷新等功能
            gridPanel.isPossibleLoad = true;
            // grid加载生效
            gridPanel.store.isLoad = true;
            var store = gridPanel.getStore();
            var newParams = {
                searchBaseCategoryId: record.data.id
//                searchActiveState: 1
            };
            // 重置翻页属性
            gridPanel.resetPage();
            // 重置查询
            gridPanel.down("#resetButton").fireEvent('click');
            // 4.0强制更改store参数写法
            var params = store.proxy.extraParams;
            Ext.apply(params, newParams);
            store.load();
        }
    }

});
